<?php


namespace app\store\controllers;


use App\common\components\BaseController;
use Illuminate\Http\Request;
use Tymon\JWTAuth\Facades\JWTAuth;


/**
 * @desc 【微果商管】--商户端--基类
 * Class StoreBaseController
 * @package App\store\controllers
 */
class StoreBaseController extends BaseController
{

    public $moduleName;

    //端口类型
    const PortType = 2;

    /**
     * 获取模拟数据
     * @param $class
     * @param $action
     * @param $code
     * @return array|mixed
     */
    public static function getStoreData($class, $action, $code = 0)
    {
        //获取数据
        return self::getData($class, $action, $code, self::PortType);
    }

    /**
     * 获取商户token
     */
    public static function current_user(Request $request) {
        $token = $request->header('Authorization');
        if ($token) {
            $user = auth('store')->user();
            if (!$user) die(errorJson('获取信息失败'));
            return $user;
        } else {
            return null;
        }
    }


}
